<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<title>商品选择</title>
	<link type="text/css" href="/css/gm.css" rel="stylesheet" />
	<script type="text/javascript" src="/js/jquery-1.11.3.min.js"></script>
	<script type="text/javascript" src="/js/coo.js"></script>
	<link type="text/css" href="/css/datepicker.css" rel="stylesheet">
	<link rel="stylesheet" href="/css/ace/assets/css/bootstrap.css" />
</head>
<style type="text/css">
#id{
	width: 150px;
	display: inline-block;
}
#keyword{
	width: 150px;
	display: inline-block;
}
#status{
	width: 150px;
	display: inline-block;

}
html,body{
	overflow-y:auto;
}
</style>
<body>
<form class="form-inline" action="?" method="get" style="padding-bottom:5px;">
<input type="hidden" name="app" id="app" value="goods" />
<input type="hidden" name="act" id="act" value="choose" />
<span> ID : </span><input type="text" name="id" id="id" value="{$id}"  class="input-medium"/> 
<span> 关键词 : </span><input type="text" name="keyword" id="keyword" value="{$keyword}" class="form-control"/>   
<select name="status" id="status" class="form-control">
	<option value="">状态</option>
	<option value="0" {if $status==='0'}selected{/if}>下架</option>
	<option value="1" {if $status==='1'}selected{/if}>正常</option>
</select> 
<button type="submit" class="btn btn-info btn-sm">
	<i class="ace-icon fa fa-search bigger-110"></i>搜索
</button>
</form>

<table id="simple-table" class="table table-striped table-bordered table-hover">
	<thead>
		<tr>
			<th>ID</th>
			<th>图片</th>
			<th>名称</th>
			<th>货号</th>
			<th>简要描述</th>
			<th>价格</th>
			<th>促销价、特价</th>
			<th>库存</th>
			<th>所属类别</th>
			<th>所属店铺</th>
			<th>所属品牌</th>
			<th>状态</th>

			<th>操作</th>
		</tr>
	</thead>

	<tbody>
		{foreach from=$rs item=row name=row}
		<tr>
			<td>{$row.id}</td>
			<td style="text-align:left;"><img src="{if $row.default_pic}{$row.default_pic}{else}/images/nopic.png{/if}" width="100" /></td>
			<td style="text-align:left;">{$row.name|truncate:20}</td>
			<td style="text-align:left;">{$row.huohao}</td>
			<td style="text-align:left;">{$row.description}</td>
			<td style="text-align:left;">{$row.price}</td>
			<td style="text-align:left;">{$row.promote_price}</td>
			<td style="text-align:left;">{$row.stocks}</td>
			<td style="text-align:left;">{$row.category_id}</td>
			<td style="text-align:left;">{$row.shop_id}</td>
			<td style="text-align:left;">{$row.brand_id}</td>
			<td style="text-align:left;">{if $row.status == 1}正常{else}下架{/if}</td>
			<td>
				<a href="#" id="{$row.id}" onclick="onget({$row.id})" class="ico2" style="color:blue;"><input type="hidden" value="{$row.name}">添加</a>
			</td>
		</tr>
		{foreachelse}
		<tr bgcolor="white"><td colspan="13" height="50">暂无记录</td></tr>
		{/foreach}	
		
	</tbody>
</table>
	<div class="mypage" style="text-align:right">
			共 {$page.num_records} 个记录  {$page.current_page} / {$page.num_pages} 页  {$page.first_page} {$page.prev} {$page.nav} {$page.next} {$page.last_page}
	</div>


<script>
$(function(){
	$('#begin_date').datepicker({
		useStyle:'datepicker2',
		readonly:false,
		showTime:true,
		showSecond:false,
		format:'yyyy-mm-dd hh:nn'
	});
	$('#end_date').datepicker({
		useStyle:'datepicker2',
		readonly:false,
		showTime:true,
		showSecond:false,
		format:'yyyy-mm-dd hh:nn'
	});
});
</script>
<script>
    var goods=window.opener.document.getElementById("goods");
	function onget(id){
        var a =document.getElementById(id);
        var name=a.getElementsByTagName("input")[0].value;
        window.opener.document.getElementById("all_goods").style.display="";
        if(goods.childElementCount==0)
        {
            goods.innerHTML = "<div id='"+id+"' style='float:left;position:relative;margin-right:10px;'><input id='"
                    +id+"' type='hidden' name='goods[]' value="
                    + id + "><label  style='padding: 5px;margin-right:5px;background: #efefef'>" +id+" : "+ name
                    + "</label><input type='image' src='/images/gm/horum_img_delete.png' width='10' height='10' style='position:absolute;right:-0.5px;top:-8.5px;' onclick='javascript:onDel("
                    +id+");'></div>";
        }else
        {
            goods.innerHTML += "<div id='"+id+"' style='float:left;position:relative;margin-right:10px;'><input id='"
                    +id+"' type='hidden' name='goods[]' value="
                    + id + "><label  style='padding: 5px;margin-right:5px;background: #efefef'>" +id+" : "+ name
                    + "</label><input type='image' src='/images/gm/horum_img_delete.png' width='10' height='10' style='position:absolute;right:-0.5px;top:-8.5px;' onclick='javascript:onDel("
                    +id+");'></div>";
        }
        document.getElementById("i").value = 1;
        document.getElementById(id).setAttribute("onclick","dele("+id+")");
        document.getElementById(id).onclick=function(){
            var picdiv = goods.getElementById(id);
            picdiv.parentNode.removeChild(picdiv);
        };
	}
</script>

